const Base = require("../base.js");

module.exports = class extends Base {
  async urlsAction() {
    const sT = Date.now();
    const post = this.post();
    const push = this.service("baidu/push");
    const result = {};
    result.errno = 0;
    result.data = await push.urls(post.url);
    result.time = Date.now() - sT;
    return this.json(this.format(result));
  }

  async updateAction() {
    const sT = Date.now();
    const post = this.post();
    const push = this.service("baidu/push");
    const result = {};
    result.errno = 0;
    result.data = await push.update(post.url);
    result.time = Date.now() - sT;
    return this.json(this.format(result));
  }

  async delAction() {
    const sT = Date.now();
    const post = this.post();
    const push = this.service("baidu/push");
    const result = {};
    result.errno = 0;
    result.data = await push.del(post.url);
    result.time = Date.now() - sT;
    return this.json(this.format(result));
  }
};
